package com.git.plane;

import java.util.Random;

/**
 * 敌机类，即是飞行物，也是敌人
 * @author lichao
 *
 * @date 2016年3月14日
 */
public class AirPlane extends FlyingObject implements Enemy{

	int speed = 2;//飞行速度
	int xSpeed;
	public AirPlane(){
		this.image = ShootGame.airplane;
		this.width = image.getWidth();
		this.height = image.getHeight();
		Random random = new Random();
		y = -this.height;
		x = random.nextInt(ShootGame.WIDTH-this.width);
		int [] ran = {-1,1};
		xSpeed = ran[random.nextInt(2)];
//		x = 200;
//		y = 100;
	}
	@Override
	public int getScore() {
		return 0;
	}
	/**
	 * 敌机的移动为y坐标不停的加加
	 */
	@Override
	void step() {
		this.x += xSpeed;
		this.y += speed;
		if (this.x > ShootGame.WIDTH - width) {
			xSpeed = -1;
		}
		if (this.x < 0) {
			xSpeed = 1;
		}
		
	}

}
